<template><div><h1 id="正则表达式" tabindex="-1"><a class="header-anchor" href="#正则表达式" aria-hidden="true">#</a> 正则表达式</h1>
<h3 id="大于等于0的数字-小数点后有一位或两位小数" tabindex="-1"><a class="header-anchor" href="#大于等于0的数字-小数点后有一位或两位小数" aria-hidden="true">#</a> 大于等于0的数字，小数点后有一位或两位小数</h3>
<blockquote>
<p>如输入的是整数时，不能以0开头（如01），如是小数时不能以两个或两个以上的0开头（如000.1）,可以输入0，但不能输入00.</p>
</blockquote>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^(0|[1-9]\d*)(\.\d{1,2})?$</span><span class="token regex-delimiter">/</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="不能输入含有中文的内容" tabindex="-1"><a class="header-anchor" href="#不能输入含有中文的内容" aria-hidden="true">#</a> 不能输入含有中文的内容</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[^\u4e00-\u9fa5]+$</span><span class="token regex-delimiter">/</span></span> 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="大于0的正整数且不能以-0-开头" tabindex="-1"><a class="header-anchor" href="#大于0的正整数且不能以-0-开头" aria-hidden="true">#</a> 大于0的正整数且不能以 0 开头</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[1-9]\d*$</span><span class="token regex-delimiter">/</span></span>  
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="把textarea中空格、逗号、换行、中文逗号转换为英文逗号-如果末尾有逗号去掉" tabindex="-1"><a class="header-anchor" href="#把textarea中空格、逗号、换行、中文逗号转换为英文逗号-如果末尾有逗号去掉" aria-hidden="true">#</a> 把textarea中空格、逗号、换行、中文逗号转换为英文逗号，如果末尾有逗号去掉</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">this</span><span class="token punctuation">.</span>textarea2<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\n</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span><span class="token punctuation">,</span> <span class="token string">','</span><span class="token punctuation">)</span>
              <span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\s+</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span><span class="token punctuation">,</span> <span class="token string">','</span><span class="token punctuation">)</span>
              <span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\，</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span><span class="token punctuation">,</span> <span class="token string">','</span><span class="token punctuation">)</span>
              <span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\,{2,}</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span><span class="token punctuation">,</span> <span class="token string">','</span><span class="token punctuation">)</span>
              <span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\,$</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="常用正则表达式" tabindex="-1"><a class="header-anchor" href="#常用正则表达式" aria-hidden="true">#</a> 常用正则表达式</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code>匹配中文字符的正则表达式： <span class="token punctuation">[</span>\u4e00<span class="token operator">-</span>\u9fa5<span class="token punctuation">]</span> 
匹配双字节字符（包括汉字在内）：<span class="token punctuation">[</span><span class="token operator">^</span>\x00<span class="token operator">-</span>\xff<span class="token punctuation">]</span> 
匹配空行的正则表达式：\n<span class="token punctuation">[</span>\s<span class="token operator">|</span> <span class="token punctuation">]</span><span class="token operator">*</span>\r 
匹配 <span class="token constant">HTML</span> 标记的正则表达式：<span class="token operator">&lt;</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">></span><span class="token punctuation">.</span><span class="token operator">*</span><span class="token operator">&lt;</span>\<span class="token operator">/</span>\<span class="token number">1</span><span class="token operator">></span><span class="token operator">|</span><span class="token operator">&lt;</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">></span>
<span class="token function">匹配首尾空格的正则表达式：</span><span class="token punctuation">(</span><span class="token operator">^</span>\s<span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span>\s<span class="token operator">*</span>$<span class="token punctuation">)</span> 
匹配 <span class="token constant">IP</span> 地址的正则表达式：<span class="token operator">/</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">/</span>g
匹配 Email 地址的正则表达式：\w<span class="token operator">+</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">-</span><span class="token operator">+</span><span class="token punctuation">.</span><span class="token punctuation">]</span>\w<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span>@\w<span class="token operator">+</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">-</span><span class="token punctuation">.</span><span class="token punctuation">]</span>\w<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span>\<span class="token punctuation">.</span>\w<span class="token operator">+</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">-</span><span class="token punctuation">.</span><span class="token punctuation">]</span>\w<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span>
匹配网址 <span class="token constant">URL</span> <span class="token literal-property property">的正则表达式：http</span><span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><span class="token punctuation">(</span><span class="token operator">/</span><span class="token punctuation">[</span>\w<span class="token operator">-</span><span class="token punctuation">]</span><span class="token operator">+</span>\<span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token operator">+</span><span class="token punctuation">[</span>\w<span class="token operator">-</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token punctuation">(</span><span class="token operator">/</span><span class="token punctuation">[</span>\w<span class="token operator">-</span> <span class="token punctuation">.</span><span class="token operator">/</span><span class="token operator">?</span><span class="token operator">%</span><span class="token operator">&amp;=</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">?</span>
sql 语句：<span class="token operator">^</span><span class="token punctuation">(</span>select<span class="token operator">|</span>drop<span class="token operator">|</span><span class="token keyword">delete</span><span class="token operator">|</span>create<span class="token operator">|</span>update<span class="token operator">|</span>insert<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token operator">*</span>$ 
非负整数：<span class="token operator">^</span>\d<span class="token operator">+</span>$ 
正整数：<span class="token operator">^</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span>$ 
非正整数：<span class="token operator">^</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token operator">-</span>\d<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token operator">+</span><span class="token punctuation">)</span><span class="token punctuation">)</span>$ 
负整数：<span class="token operator">^</span><span class="token operator">-</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span>$ 
整数：<span class="token operator">^</span><span class="token operator">-</span><span class="token operator">?</span>\d<span class="token operator">+</span>$ 
非负浮点数：<span class="token operator">^</span>\d<span class="token operator">+</span><span class="token punctuation">(</span>\<span class="token punctuation">.</span>\d<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">?</span>$ 
正浮点数：<span class="token operator">^</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token operator">+</span>\<span class="token punctuation">.</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span>\<span class="token punctuation">.</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token punctuation">)</span>$ 
非正浮点数：<span class="token operator">^</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token operator">-</span>\d<span class="token operator">+</span>\<span class="token punctuation">.</span>\d<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">?</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token operator">+</span><span class="token punctuation">(</span>\<span class="token number">.0</span><span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">?</span><span class="token punctuation">)</span><span class="token punctuation">)</span>$ 
英文字符串：<span class="token operator">^</span><span class="token punctuation">[</span><span class="token constant">A</span><span class="token operator">-</span>Za<span class="token operator">-</span>z<span class="token punctuation">]</span><span class="token operator">+</span>$ 
英文大写串：<span class="token operator">^</span><span class="token punctuation">[</span><span class="token constant">A</span><span class="token operator">-</span><span class="token constant">Z</span><span class="token punctuation">]</span><span class="token operator">+</span>$ 
英文小写串：<span class="token operator">^</span><span class="token punctuation">[</span>a<span class="token operator">-</span>z<span class="token punctuation">]</span><span class="token operator">+</span>$ 
英文字符数字串：<span class="token operator">^</span><span class="token punctuation">[</span><span class="token constant">A</span><span class="token operator">-</span>Za<span class="token operator">-</span>z0<span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">+</span>$ 
英数字加下划线串：<span class="token operator">^</span>\w<span class="token operator">+</span>$ 
<span class="token constant">E</span><span class="token operator">-</span>mail地址：<span class="token operator">^</span><span class="token punctuation">[</span>\w<span class="token operator">-</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token punctuation">(</span>\<span class="token punctuation">.</span><span class="token punctuation">[</span>\w<span class="token operator">-</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span>@<span class="token punctuation">[</span>\w<span class="token operator">-</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token punctuation">(</span>\<span class="token punctuation">.</span><span class="token punctuation">[</span>\w<span class="token operator">-</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">+</span>$ 
<span class="token constant">URL</span>：<span class="token operator">^</span><span class="token punctuation">[</span>a<span class="token operator">-</span>zA<span class="token operator">-</span><span class="token constant">Z</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><span class="token punctuation">(</span>\w<span class="token operator">+</span><span class="token punctuation">(</span><span class="token operator">-</span>\w<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token punctuation">(</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\w<span class="token operator">+</span><span class="token punctuation">(</span><span class="token operator">-</span>\w<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">*</span><span class="token punctuation">(</span>\<span class="token operator">?</span>\s<span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">?</span>$ 或：<span class="token operator">^</span>http<span class="token operator">:</span>\<span class="token operator">/</span>\<span class="token operator">/</span><span class="token punctuation">[</span><span class="token constant">A</span><span class="token operator">-</span>Za<span class="token operator">-</span>z0<span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">+</span>\<span class="token punctuation">.</span><span class="token punctuation">[</span><span class="token constant">A</span><span class="token operator">-</span>Za<span class="token operator">-</span>z0<span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token punctuation">[</span>\<span class="token operator">/=</span>\<span class="token operator">?</span><span class="token operator">%</span>\<span class="token operator">-</span><span class="token operator">&amp;</span>_<span class="token operator">~</span>`@<span class="token punctuation">[</span>\<span class="token punctuation">]</span>\'<span class="token operator">:</span><span class="token operator">+</span><span class="token operator">!</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">^</span><span class="token operator">&lt;</span><span class="token operator">></span>\"\"<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">*</span>$ 
邮政编码：<span class="token operator">^</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span>\d<span class="token punctuation">{</span><span class="token number">5</span><span class="token punctuation">}</span>$ 
电话号码：<span class="token operator">^</span><span class="token punctuation">(</span><span class="token punctuation">(</span>\<span class="token punctuation">(</span>\d<span class="token punctuation">{</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">}</span>\<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span>\d<span class="token punctuation">{</span><span class="token number">3</span><span class="token punctuation">}</span>\<span class="token operator">-</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">?</span><span class="token punctuation">(</span>\<span class="token punctuation">(</span><span class="token number">0</span>\d<span class="token punctuation">{</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">}</span>\<span class="token punctuation">)</span><span class="token operator">|</span><span class="token number">0</span>\d<span class="token punctuation">{</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">}</span><span class="token operator">-</span><span class="token punctuation">)</span><span class="token operator">?</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span>\d<span class="token punctuation">{</span><span class="token number">6</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">}</span><span class="token punctuation">(</span>\<span class="token operator">-</span>\d<span class="token punctuation">{</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token operator">?</span>$ 
手机号码：<span class="token operator">^</span><span class="token punctuation">(</span><span class="token punctuation">(</span>\<span class="token punctuation">(</span>\d<span class="token punctuation">{</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">}</span>\<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span>\d<span class="token punctuation">{</span><span class="token number">3</span><span class="token punctuation">}</span>\<span class="token operator">-</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">?</span><span class="token number">13</span>\d<span class="token punctuation">{</span><span class="token number">9</span><span class="token punctuation">}</span>$ 
双字节字符（包括汉字在内）：<span class="token operator">^</span>\x00<span class="token operator">-</span>\xff 
<span class="token function">匹配首尾空格：</span><span class="token punctuation">(</span><span class="token operator">^</span>\s<span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span>\s<span class="token operator">*</span>$<span class="token punctuation">)</span>
匹配 <span class="token constant">HTML</span> 标记：<span class="token operator">&lt;</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">></span><span class="token punctuation">.</span><span class="token operator">*</span><span class="token operator">&lt;</span>\<span class="token operator">/</span>\<span class="token number">1</span><span class="token operator">></span><span class="token operator">|</span><span class="token operator">&lt;</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token operator">></span> 
匹配空行：\n<span class="token punctuation">[</span>\s<span class="token operator">|</span> <span class="token punctuation">]</span><span class="token operator">*</span>\r 
<span class="token function">提取信息中的网络链接：</span><span class="token punctuation">(</span>h<span class="token operator">|</span><span class="token constant">H</span><span class="token punctuation">)</span><span class="token punctuation">(</span>r<span class="token operator">|</span><span class="token constant">R</span><span class="token punctuation">)</span><span class="token punctuation">(</span>e<span class="token operator">|</span><span class="token constant">E</span><span class="token punctuation">)</span><span class="token punctuation">(</span>f<span class="token operator">|</span><span class="token constant">F</span><span class="token punctuation">)</span> <span class="token operator">*=</span> <span class="token operator">*</span><span class="token punctuation">(</span><span class="token string">'|")?(\w|\\|\/|\.)+('</span><span class="token operator">|</span>"<span class="token operator">|</span> <span class="token operator">*</span><span class="token operator">|</span><span class="token operator">></span><span class="token punctuation">)</span><span class="token operator">?</span> 
提取信息中的邮件地址：\w<span class="token operator">+</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">-</span><span class="token operator">+</span><span class="token punctuation">.</span><span class="token punctuation">]</span>\w<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span>@\w<span class="token operator">+</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">-</span><span class="token punctuation">.</span><span class="token punctuation">]</span>\w<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span>\<span class="token punctuation">.</span>\w<span class="token operator">+</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">-</span><span class="token punctuation">.</span><span class="token punctuation">]</span>\w<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">*</span> 
<span class="token function">提取信息中的图片链接：</span><span class="token punctuation">(</span>s<span class="token operator">|</span><span class="token constant">S</span><span class="token punctuation">)</span><span class="token punctuation">(</span>r<span class="token operator">|</span><span class="token constant">R</span><span class="token punctuation">)</span><span class="token punctuation">(</span>c<span class="token operator">|</span><span class="token constant">C</span><span class="token punctuation">)</span> <span class="token operator">*=</span> <span class="token operator">*</span><span class="token punctuation">(</span><span class="token string">'|")?(\w|\\|\/|\.)+('</span><span class="token operator">|</span>"<span class="token operator">|</span> <span class="token operator">*</span><span class="token operator">|</span><span class="token operator">></span><span class="token punctuation">)</span><span class="token operator">?</span> 
提取信息中的 <span class="token constant">IP</span> <span class="token function">地址：</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span> 
<span class="token function">提取信息中的中国手机号码：</span><span class="token punctuation">(</span><span class="token number">86</span><span class="token punctuation">)</span><span class="token operator">*</span><span class="token number">0</span><span class="token operator">*</span><span class="token number">13</span>\d<span class="token punctuation">{</span><span class="token number">9</span><span class="token punctuation">}</span> 
<span class="token function">提取信息中的中国固定电话号码：</span><span class="token punctuation">(</span>\<span class="token punctuation">(</span>\d<span class="token punctuation">{</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">}</span>\<span class="token punctuation">)</span><span class="token operator">|</span>\d<span class="token punctuation">{</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">}</span><span class="token operator">-</span><span class="token operator">|</span>\s<span class="token punctuation">)</span><span class="token operator">?</span>\d<span class="token punctuation">{</span><span class="token number">8</span><span class="token punctuation">}</span> 
<span class="token function">提取信息中的中国电话号码（包括移动和固定电话）：</span><span class="token punctuation">(</span>\<span class="token punctuation">(</span>\d<span class="token punctuation">{</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">}</span>\<span class="token punctuation">)</span><span class="token operator">|</span>\d<span class="token punctuation">{</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">}</span><span class="token operator">-</span><span class="token operator">|</span>\s<span class="token punctuation">)</span><span class="token operator">?</span>\d<span class="token punctuation">{</span><span class="token number">7</span><span class="token punctuation">,</span><span class="token number">14</span><span class="token punctuation">}</span> 
提取信息中的中国邮政编码：<span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token number">1</span><span class="token punctuation">}</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token number">5</span><span class="token punctuation">}</span> 
<span class="token function">提取信息中的浮点数（即小数）：</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token operator">?</span>\d<span class="token operator">*</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token operator">?</span>\d<span class="token operator">+</span> 
提取信息中的任何数字 <span class="token function">：</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token operator">?</span>\d<span class="token operator">*</span><span class="token punctuation">)</span><span class="token punctuation">(</span>\<span class="token punctuation">.</span>\d<span class="token operator">+</span><span class="token punctuation">)</span><span class="token operator">?</span> 
<span class="token constant">IP</span><span class="token function">：</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span>\<span class="token punctuation">.</span><span class="token punctuation">(</span>\d<span class="token operator">+</span><span class="token punctuation">)</span> 
电话区号：<span class="token operator">^</span><span class="token number">0</span>\d<span class="token punctuation">{</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">}</span>$
腾讯 <span class="token constant">QQ</span> 号：<span class="token operator">^</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">*</span>$ 
帐号（字母开头，允许 <span class="token number">5</span><span class="token operator">-</span><span class="token number">16</span> 字节，允许字母数字下划线）：<span class="token operator">^</span><span class="token punctuation">[</span>a<span class="token operator">-</span>zA<span class="token operator">-</span><span class="token constant">Z</span><span class="token punctuation">]</span><span class="token punctuation">[</span>a<span class="token operator">-</span>zA<span class="token operator">-</span><span class="token constant">Z0</span><span class="token operator">-</span>9_<span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">15</span><span class="token punctuation">}</span>$ 
中文、英文、数字及下划线：<span class="token operator">^</span><span class="token punctuation">[</span>\u4e00<span class="token operator">-</span>\u9fa5_a<span class="token operator">-</span>zA<span class="token operator">-</span><span class="token constant">Z0</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span><span class="token operator">+</span>$
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="手机号码的校验" tabindex="-1"><a class="header-anchor" href="#手机号码的校验" aria-hidden="true">#</a> 手机号码的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> phoneReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[1][3,4,5,6,7,8,9][0-9]{9}$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> phoneStr1 <span class="token operator">=</span> <span class="token string">'18886233487'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>phoneReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>phoneStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> phoneStr2 <span class="token operator">=</span> <span class="token string">'17283017203897'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>phoneReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>phoneStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="身份证的校验" tabindex="-1"><a class="header-anchor" href="#身份证的校验" aria-hidden="true">#</a> 身份证的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> sfzReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> sfzStr1 <span class="token operator">=</span> <span class="token string">'415106199801012130'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>sfzReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>sfzStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> sfzStr2 <span class="token operator">=</span> <span class="token string">'718381298381212183'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>sfzReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>sfzStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="邮箱的校验" tabindex="-1"><a class="header-anchor" href="#邮箱的校验" aria-hidden="true">#</a> 邮箱的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> emailReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> emailStrWY <span class="token operator">=</span> <span class="token string">'956666@163.com'</span> <span class="token comment">// 163邮箱const emailStrQQ = '956666@qq.com' // qq邮箱console.log(emailReg.test(emailStrWY)) // trueconsole.log(emailReg.test(emailStrQQ)) // true</span>
<span class="token keyword">const</span> noEmail <span class="token operator">=</span> <span class="token string">'72873213.com'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>emailReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>noEmail<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="url的校验" tabindex="-1"><a class="header-anchor" href="#url的校验" aria-hidden="true">#</a> URL的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> urlReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> urlStr1 <span class="token operator">=</span> <span class="token string">'https://haha.sunshine.com/xxx/xxx'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>urlReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>urlStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> urlStr2 <span class="token operator">=</span> <span class="token string">'sss://haha.sunshine.com/xxx/xxx'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>urlReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>urlStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="ipv4的校验" tabindex="-1"><a class="header-anchor" href="#ipv4的校验" aria-hidden="true">#</a> IPv4的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> ipv4Reg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> ipv4Str1 <span class="token operator">=</span> <span class="token string">'122.12.56.65'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>ipv4Reg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>ipv4Str1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> ipv4Str2 <span class="token operator">=</span> <span class="token string">'122.12.56.655'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>ipv4Reg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>ipv4Str2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="_16进制颜色的校验" tabindex="-1"><a class="header-anchor" href="#_16进制颜色的校验" aria-hidden="true">#</a> 16进制颜色的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> color16Reg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> color16Str1 <span class="token operator">=</span> <span class="token string">'#fff'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>color16Reg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>color16Str1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> color16Str2 <span class="token operator">=</span> <span class="token string">'#1234567'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>color16Reg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>color16Str2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="日期-yyyy-mm-dd" tabindex="-1"><a class="header-anchor" href="#日期-yyyy-mm-dd" aria-hidden="true">#</a> 日期 YYYY-MM-DD</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> dateReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^\d{4}(\-)\d{1,2}\1\d{1,2}$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> dateStr1 <span class="token operator">=</span> <span class="token string">'2021-10-10'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dateReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>dateStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> dateStr2 <span class="token operator">=</span> <span class="token string">'2021-01-01 1'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dateReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>dateStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="日期-yyyy-mm-dd-hh-mm-ss" tabindex="-1"><a class="header-anchor" href="#日期-yyyy-mm-dd-hh-mm-ss" aria-hidden="true">#</a> 日期 YYYY-MM-DD hh:mm:ss</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> dateReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> dateStr1 <span class="token operator">=</span> <span class="token string">'2021-10-10 16:16:16'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dateReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>dateStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> dateStr2 <span class="token operator">=</span> <span class="token string">'2021-10-10 16:'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dateReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>dateStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="整数的校验" tabindex="-1"><a class="header-anchor" href="#整数的校验" aria-hidden="true">#</a> 整数的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> intReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[-+]?\d*$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> intNum1 <span class="token operator">=</span> 12345console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>intReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>intNum1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> intNum2 <span class="token operator">=</span> <span class="token number">12345</span><span class="token punctuation">.</span>1console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>intReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>intNum2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="小数的校验" tabindex="-1"><a class="header-anchor" href="#小数的校验" aria-hidden="true">#</a> 小数的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> floatReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[-\+]?\d+(\.\d+)?$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> floatNum <span class="token operator">=</span> <span class="token number">1234</span><span class="token punctuation">.</span>5console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>floatReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>floatNum<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="保留n位小数" tabindex="-1"><a class="header-anchor" href="#保留n位小数" aria-hidden="true">#</a> 保留n位小数</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">function</span> <span class="token function">checkFloat</span><span class="token punctuation">(</span><span class="token parameter">n</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">RegExp</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">^([1-9]+[\d]*(.[0-9]{1,</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>n<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">})?)$</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">}</span><span class="token comment">// 保留2位小数const floatReg = checkFloat(2)</span>
<span class="token keyword">const</span> floatNum1 <span class="token operator">=</span> <span class="token number">1234</span><span class="token punctuation">.</span>5console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>floatReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>floatNum1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> floatNum2 <span class="token operator">=</span> <span class="token number">1234</span><span class="token punctuation">.</span>55console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>floatReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>floatNum2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> floatNum3 <span class="token operator">=</span> <span class="token number">1234</span><span class="token punctuation">.</span>555console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>floatReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>floatNum3<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="邮政编号的校验" tabindex="-1"><a class="header-anchor" href="#邮政编号的校验" aria-hidden="true">#</a> 邮政编号的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> postalNoReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^\d{6}$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> postalNoStr1 <span class="token operator">=</span> <span class="token string">'522000'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>postalNoReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>postalNoStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> postalNoStr2 <span class="token operator">=</span> <span class="token string">'5220000'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>postalNoReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>postalNoStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="qq号的校验" tabindex="-1"><a class="header-anchor" href="#qq号的校验" aria-hidden="true">#</a> QQ号的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code>说明：<span class="token number">5</span><span class="token operator">-</span><span class="token number">11</span>位数字
<span class="token keyword">const</span> qqReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[1-9][0-9]{4,10}$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> qqStr1 <span class="token operator">=</span> <span class="token string">'1915801633'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>qqReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>qqStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> qqStr2 <span class="token operator">=</span> <span class="token string">'191580163333'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>qqReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>qqStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="微信号的校验" tabindex="-1"><a class="header-anchor" href="#微信号的校验" aria-hidden="true">#</a> 微信号的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code>说明：<span class="token number">6</span>至<span class="token number">20</span>位，以字母开头，字母，数字，减号，下划线
<span class="token keyword">const</span> wxReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> wxStr1 <span class="token operator">=</span> <span class="token string">'linsanxin885577'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>wxReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>wxStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> wxStr2 <span class="token operator">=</span> <span class="token string">'厉害了我的vx'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>wxReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>wxStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="车牌号的校验" tabindex="-1"><a class="header-anchor" href="#车牌号的校验" aria-hidden="true">#</a> 车牌号的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> carNoReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> carNoStr1 <span class="token operator">=</span> <span class="token string">'粤A12345'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>carNoReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>carNoStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> carNoStr2 <span class="token operator">=</span> <span class="token string">'广东A12345'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>carNoReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>carNoStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="只含字母的字符串" tabindex="-1"><a class="header-anchor" href="#只含字母的字符串" aria-hidden="true">#</a> 只含字母的字符串</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> letterReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-zA-Z]+$</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> letterStr1 <span class="token operator">=</span> <span class="token string">'sunshineLin'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>letterReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>letterStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> letterStr2 <span class="token operator">=</span> <span class="token string">'sunshine_Lin'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>letterReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>letterStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="包含中文的字符串" tabindex="-1"><a class="header-anchor" href="#包含中文的字符串" aria-hidden="true">#</a> 包含中文的字符串</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> cnReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">[\u4E00-\u9FA5]</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> cnStr1 <span class="token operator">=</span> <span class="token string">'我是sunshine_Lin，林三心'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>cnReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>cnStr1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> cnStr2 <span class="token operator">=</span> <span class="token string">'sunshine_Lin'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>cnReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>cnStr2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="密码强度的校验" tabindex="-1"><a class="header-anchor" href="#密码强度的校验" aria-hidden="true">#</a> 密码强度的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code>说明：密码中必须包含字母、数字、特称字符，至少<span class="token number">8</span>个字符，最多<span class="token number">30</span>个字符
<span class="token keyword">const</span> passwordReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,30}</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> password1 <span class="token operator">=</span> <span class="token string">'sunshine_Lin12345..'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>passwordReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>password1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> password2 <span class="token operator">=</span> <span class="token string">'sunshineLin12345'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>passwordReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>password2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="字符串长度n的校验" tabindex="-1"><a class="header-anchor" href="#字符串长度n的校验" aria-hidden="true">#</a> 字符串长度n的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">function</span> <span class="token function">checkStrLength</span><span class="token punctuation">(</span><span class="token parameter">n</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">RegExp</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">^.{</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>n<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">}$</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">}</span>
<span class="token comment">// 校验长度为3的字符串const lengthReg = checkStrLength(3)</span>
<span class="token keyword">const</span> str1 <span class="token operator">=</span> <span class="token string">'hhh'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>lengthReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>str1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token keyword">const</span> str2 <span class="token operator">=</span> <span class="token string">'hhhhh'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>lengthReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>str2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="文件拓展名的校验" tabindex="-1"><a class="header-anchor" href="#文件拓展名的校验" aria-hidden="true">#</a> 文件拓展名的校验</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">function</span> <span class="token function">checkFileName</span> <span class="token punctuation">(</span><span class="token parameter">arr</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>  arr <span class="token operator">=</span> arr<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token parameter">name</span> <span class="token operator">=></span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">.</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>name<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token string">'|'</span><span class="token punctuation">)</span>  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">RegExp</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">(</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>arr<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">)$</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">}</span>
<span class="token keyword">const</span> filenameReg <span class="token operator">=</span> <span class="token function">checkFileName</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">'jpg'</span><span class="token punctuation">,</span> <span class="token string">'png'</span><span class="token punctuation">,</span> <span class="token string">'txt'</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token keyword">const</span> filename1 <span class="token operator">=</span> <span class="token string">'sunshine.jpg'</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>filenameReg<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>filename1<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment">// trueconst filename2 = 'sunshine.png'console.log(filenameReg.test(filename2)) // trueconst filename3 = 'sunshine.txt'console.log(filenameReg.test(filename3)) // trueconst filename4 = 'sunshine.md'console.log(filenameReg.test(filename4)) // false</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-text ext-text line-numbers-mode"><pre v-pre class="language-text"><code>### 匹配img和src
```js
const imgReg = /&lt;img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/ig
const htmlStr = '&lt;div>&lt;/div>&lt;img src="sunshine.png" />&lt;img src="sunshine111.png" />'
console.log(imgReg.exec(htmlStr))// [//   '&lt;img src="sunshine.png" />',//   'sunshine.png',//   index: 11,//   input: '&lt;div>&lt;/div>&lt;img src="sunshine.png" />&lt;img src="sunshine111.png" />',//   groups: undefined// ]console.log(imgReg.exec(htmlStr))// [//   '&lt;img src="sunshine111.png" />',//   'sunshine111.png',//   index: 37,//   input: '&lt;div>&lt;/div>&lt;img src="sunshine.png" />&lt;img src="sunshine111.png" />',//   groups: undefined// ]
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="匹配html中的注释" tabindex="-1"><a class="header-anchor" href="#匹配html中的注释" aria-hidden="true">#</a> 匹配html中的注释</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> noteReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">&lt;!--(.*?)--></span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span>
<span class="token keyword">const</span> htmlStr <span class="token operator">=</span> <span class="token string">'&lt;!--一个div标签--> &lt;div>&lt;/div> &lt;!--一个div标签--> &lt;div>&lt;/div>'</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>noteReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token comment">// [//   '&lt;!--一个div标签-->',//   '一个div标签',//   index: 0,//   input: '&lt;!--一个div标签--> &lt;div>&lt;/div> &lt;!--一个div标签--> &lt;div>&lt;/div>',//   groups: undefined// ]console.log(noteReg.exec(htmlStr))// [//   '&lt;!--一个div标签-->',//   '一个div标签',//   index: 27,//   input: '&lt;!--一个div标签--> &lt;div>&lt;/div> &lt;!--一个div标签--> &lt;div>&lt;/div>',//   groups: undefined// ]</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="匹配html中的style" tabindex="-1"><a class="header-anchor" href="#匹配html中的style" aria-hidden="true">#</a> 匹配html中的style</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> styleReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">([(\s+\w+=)|>])</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span>
<span class="token keyword">const</span> htmlStr <span class="token operator">=</span> <span class="token string">'&lt;div>&lt;span>&lt;/span>&lt;/div>'</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>styleReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token comment">// [//   '>',//   '>',//   index: 5,//   input: '&lt;div>&lt;span>&lt;/span>&lt;/div>',//   groups: undefined// ]console.log(styleReg.exec(htmlStr))// [//   '>',//   '>',//   index: 36,//   input: '&lt;div>&lt;span>&lt;/span>&lt;/div>',//   groups: undefined// ]</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="匹配html中的颜色" tabindex="-1"><a class="header-anchor" href="#匹配html中的颜色" aria-hidden="true">#</a> 匹配html中的颜色</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> colorReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})</span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span>
<span class="token keyword">const</span> htmlStr <span class="token operator">=</span> <span class="token string">'&lt;div>&lt;span>&lt;/span>&lt;/div>'</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>colorReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token comment">// [//   '#000',//   '000',//   index: 23,//   input: '&lt;div>&lt;span>&lt;/span>&lt;/div>',//   groups: undefined// ]console.log(colorReg.exec(htmlStr))// [//   '#fff',//   'fff',//   index: 49,//   input: '&lt;div>&lt;span>&lt;/span>&lt;/div>',//   groups: undefined// ]</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="匹配htmltag-html标签" tabindex="-1"><a class="header-anchor" href="#匹配htmltag-html标签" aria-hidden="true">#</a> 匹配htmlTag（html标签）</h3>
<div class="language-javascript ext-js line-numbers-mode"><pre v-pre class="language-javascript"><code><span class="token keyword">const</span> endReg <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">&lt;("[^"]*"|'[^']*'|[^'">])*></span><span class="token regex-delimiter">/</span><span class="token regex-flags">g</span></span>
<span class="token keyword">const</span> htmlStr <span class="token operator">=</span> <span class="token string">'&lt;div>&lt;span>&lt;/span>&lt;/div>&lt;h1>&lt;/h1>'</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>endReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>endReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>endReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>endReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>endReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>endReg<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>htmlStr<span class="token punctuation">)</span><span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></div></template>


